#include <vector>
#include <iostream>

template<typename T>
class CircularArray
{
	std::vector<T> _data;
	size_t _idxHead;
public:
	explicit CircularArray(size_t size) : _data(size), _idxHead(0) {}

	void advance() { _idxHead = (_idxHead + 1) % _data.size(); }

	T& operator[](size_t index)
	{
		return _data[(_idxHead + index) % _data.size()];
	}

	const T& operator[](size_t index) const
	{
		return _data[(_idxHead + index) % _data.size()];
	}

	const T& front() const
	{
		return _data[_idxHead];
	}

	size_t size() const
	{
		return _data.size();
	}
};

struct Foo
{
	size_t index;
	size_t index1;
	char* pointer;
	Foo() : index(0), index1(0), pointer(0) {}
	Foo(size_t i, size_t i1, char* ptr) : index(i), index1(i1), pointer(ptr) {}
};

int Test_Utils(int, char**)
{
	CircularArray<Foo> ca(10);

	char* p1 = "p1";
	char* p2 = "p2";

	ca[0] = Foo(0, 1, p1);
	size_t i = ca[0].index;
	ca.advance();
	ca[0] = Foo(1, 2, p2);
	i = ca[0].index;
	ca[9] = Foo(1, 2, p2);
	i = ca.front().index;

	return 0;
}